<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<c:if test="${empty pass}">
    <c:redirect url="magazine_manager"></c:redirect>
</c:if>

<script type="text/javascript" src = "rsrc/js/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src = "rsrc/js/jquery.validationEngine.js"></script>

<script>
    $(document).ready(function(){
        $('#magazine_form').validationEngine('attach');
        $('#cancelMagazineForm').click(function(){           
           $('#magazine_form').validationEngine('hideAll'); 
           $('#magazine_form').validationEngine('detach');
        });
    });
</script>
<div class="separator"></div>
<div id="magazine_part">
    <c:if test="${!empty magazine}" >
        <p class="page_label">Add New Magazine</p>
    </c:if>
    <c:if test="${empty magazine}" >
        <p class="page_label">Add New Magazine</p>
    </c:if>
  
  <form id="magazine_form" action="add_magazine_action" method="post" >
        <table id="magazine_form_table">
            <tr>
                <td class="label" align="left">Magazine Title</td>
                <td align="left"><input type='text' <c:if test="${!empty magazine}"> value="${magazine.title}" </c:if> name='magazineTitle' id='magazineTitle' class="validate[required,custom[onlyLetterNumber]] input_text" title=""/>*</td>
            </tr>                    
            <tr>
                <td class="label" align="left">Issue:</td>
                <td align="left"><input type='text' <c:if test="${!empty magazine}"> value="${magazine.issue}" </c:if> name='issue' id='issue' class="validate[required,custom[onlyLetterNumber]] input_text" title=""/>*</td>
            </tr>
            <tr>
                <td class="label" align="left">Editor:</td>
                <td align="left"><input type='text' <c:if test="${!empty magazine}"> value="${magazine.editor}" </c:if> name='editor' id='editor' class="validate[required,custom[onlyLetterSp]] input_text" title=""/>*</td>
            </tr>
            <tr>
                <td class="label" align="left">Frequency:</td>
                <td align="left"><input type='text' <c:if test="${!empty magazine}"> value="${magazine.frequency}" </c:if> name='frequency' id='frequency' class="validate[required,custom[onlyLetterSp]] input_text" title=""/>*</td>
            </tr>
            <tr>
                <td class="label" align="left">Price:</td>
                <td align="left"><input type='text' <c:if test="${!empty magazine}"> value="${magazine.price}" </c:if> name='magazinePrice' id = 'magazinePrice' class="validate[required,custom[number]] input_text" title=""/>*</td>
            </tr>
            <tr>
                <td class="label" align="left">Synopsis</td>
                <td align="left"><textarea cols="45" rows="5" name="synopsis" id="synopsis" class="validate[required] input_text" title=""><c:if test="${!empty magazine}"> ${magazine.synopsis} </c:if></textarea>*</td>
            </tr>
            <tr>
                <td align="left"></td><td align = "left"><input id='formMagazineButton' type='submit' class='gb' value='Submit' name='formMagazineButton' /><input id='cancelMagazineForm' type='button' class='gb' value='Cancel' name='cancelMagazineForm' /></td>
            </tr>            
        </table>
        <span class="label">Fields with * are required</span>
        <c:if test="${!empty magazine}"> <input type="hidden" name="m" id="m" value="${magazine.productCrypt}"/> </c:if>
        <input type="hidden" name="formType" id="formType" value="${formType}"/>
    </form>
</div>